

import 'package:moonplay/provide/provide.dart';
import 'package:flutter/material.dart';
import 'package:moonplay/common/app_common.dart';


class CommonStyle{
  static dynamic ctx;
  
  /*
  * 下划线(颜色随主题色变化, 日间主题时为黑色, 夜间主题时为白色)
  * left 左偏移量
  * right 右偏移量
  * opacity 透明度 值为1 - 10
  * 用法：bottomLine(left: 30.0),{}里面为可选参数，加参数必须带上参数名
  */
  static Widget bottomLine({double left, double right, int opacity}){
    int opacityNum = 50;
    Color _bgmColor;
    if(opacity != null) {
      opacityNum = opacity * 25;
    }

    var _provideColor = Provide.value<ThemeProvider>(ctx).getThemeMode();
    if(_provideColor == ThemeMode.dark) {
      _bgmColor = Color.fromARGB(opacityNum, 255, 255, 255);
    } else {
      //日间模式
      _bgmColor = Color.fromARGB(opacityNum, 0, 0, 0);
    }
    
    return SizedBox(
      child: Container(
        margin: EdgeInsets.only(left: left != null ? ScreenUtil().getWidthPx(left) : 0, right: right != null ? ScreenUtil().getWidthPx(right) : 0),
        height: 0.3,
        color: _bgmColor
      ),
    );
  }

  /**
   * icon图标
   * iconText 图标text
   * iconSize 图标大小
   * iconColor图标颜色
   * 颜色随主题色变化(日间主题时为黑色, 夜间主题时为白色)
   */
  static Widget icons(int iconText, {double iconSize, Color iconColor}){
    Color _iconColor;
    var _provideColor = Provide.value<ThemeProvider>(ctx).getThemeMode();
    if(_provideColor == ThemeMode.dark) {
      _iconColor = Color.fromARGB(50, 255, 255, 255);
    } else {
      //日间模式
      _iconColor = Color.fromARGB(100, 0, 0, 0);
    }
    return Icon(IconData(
        iconText,
        fontFamily: Constants.IconFontFamily,
      ),
      size: ScreenUtil().getSp(iconSize),
      color: iconColor != null ? iconColor : _iconColor,
    );
  }
}
